<?php
/**
 * View  LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    24-nov-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
    //<![CDATA[
     
    //]]>
</script>

<div id="content" class="live-detail">
    <div id="summary" class="live">
        <div class="head live">
            <h2>Riepilogo Live:</h2>
            <div class="live-status">
                <span class="<?php echo $this->data['live_status']['live_status_mark'] ?>"><?php echo $this->data['live_status']['live_status_name'] ?></span>
            </div>
        </div>
        <div class="body">
            <table cellspacing="0" class="table">
                <tbody>
                    <tr>
                        <th>Artista/i:</th>
                        <td>
                            <strong>
                                <?php
                                foreach( $this->data['artists']['main'] as $artist ) :
                                    $artists_list .= $artist['artist_name'] . ', ';
                                endforeach;
                                ?>
                                <?php echo substr( $artists_list, 0, -2 ); ?>
                            </strong>
                        </td>
                    </tr>
                    <?php if( count( $this->data['artists']['openingact'] ) ): ?>
                        <tr>
                            <th>Opening-act:</th>
                            <td>
                                <strong>
                                    <?php
                                    $artists_list = null;
                                    foreach( $this->data['artists']['openingact'] as $artist ) :
                                        $artists_list .= $artist['artist_name'] . ', ';
                                    endforeach;
                                    ?>
                                    <?php echo substr( $artists_list, 0, -2 ); ?>				
                                </strong>
                            </td>
                        </tr>			
                    <?php endif; ?>
                    <tr>
                        <th>Location:</th>
                        <td><strong><?php echo $this->data['location']['location_name'] ?>, <?php echo $this->data['location']['location_city'] ?> (<?php echo $this->province[$this->data['location']['location_province_id']]['province_short_name'] ?>)</strong></td>
                    </tr>
                    <tr>
                        <th>Quando:</th>
                        <td><strong><?php echo $this->days[date( 'N', mktime( $hour, $minute, $second, $this->live['month'], $this->live['day'], $this->live['year'] ) )] ?> <?php echo $this->data['day'] ?>-<?php echo $this->months[date( 'n', mktime( $hour, $minute, $second, $this->live['month'], $this->live['day'], $this->live['year'] ) )] ?>-<?php echo $this->data['year'] ?></strong> alle <strong><?php echo $this->data['live_stagetime_ita'] ?></strong></td>
                    </tr>
                    <tr class="break">
                        <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <th>Ingresso:</th>
                        <td><?php echo $this->data['live_price_1'] ? $this->data['live_price_1'] . ',' . $this->data['live_price_2'] . ' &euro;' : 'gratuito' ?></td>
                    </tr>
                    <tr>
                        <th>Apertura Cancelli:</th>
                        <td><?php echo $this->data['live_gate_open_h'] ? $this->data['live_gate_open_h'] . 'h' . $this->data['live_gate_open_m'] : '' ?></td>
                    </tr>
                    <tr>
                        <th>Note:</th>
                        <td><?php echo $this->data['live_notes'] ?></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>    
<!--    Dove?   -->
    <div class="col2">
        <div id="detailTableLeft">
            <div class="detail-box location">
                <div class="box-head">
                    <strong>Dettagli Location</strong>
                </div>
                <div class="box-body">
                    <table cellspacing="0" class="table">
                        <tbody>
                            <tr>
                                <th>Nome:</th>
                                <td><?php echo $this->data['location']['location_name']?></td>
                            </tr>
                            <tr>
                                <th>Indirizzo:</th>
                                <td>			
                                <?php 
                                $address = NULL;

                                if( $this->data['location']['location_street'] != '' )
                                    $address .= $this->data['location']['location_street'] .', ';

                                if( $this->data['location']['location_street_number'] != '' )
                                    $address .= 'N&deg; '. $this->data['location']['location_street_number'] .'<br /> ';

                                if( $this->data['location']['location_loc'] != '' )
                                    $address .= 'Localit&aacute; '. $this->data['location']['location_loc'] .'<br />';

                                if( $this->data['location']['location_cap'] != '' )
                                    $address .= $this->data['location']['location_cap'];

                                if( $this->data['location']['location_city'] != '' )
                                    $address .= ' <strong>'. strtoupper( $this->data['location']['location_city'] ) .'</strong> ';

                                if( $this->data['location']['location_province_id'] != '' )
                                    $address .= '('. $this->province[$this->data['location']['location_province_id']]['province_long_name'] .')';

                                if( $address !== NULL )
                                {
                                    echo $address;
                                }
                                ?>
                                </td>
                            </tr>
                            <tr>
                                <th>Info Locale:</th>
                                <td><?php echo $this->data['location']['location_desc']?></td>
                            </tr>	
                
                        </tbody>
                    </table>
                    
                </div>  
                <div class="box-head">
                    <strong>Contatti Location</strong>
                </div>
                <div class="box-body">
                    <table cellspacing="0" class="table">
                        <tbody>
                            <?php
                            if( is_array( $this->data['location']['location_contacts'] ) ):
                                foreach( $this->data['location']['location_contacts'] AS $contact ): ?>
                            <tr>
                                <th class="section">Nome:</th>
                                <td class="section"><strong><a href="/admin/contatti/vedi/id/<?php echo $contact['contact_id']?>"><?php echo $contact['contact_firstname']?> <?php echo $contact['contact_lastname']?></a></strong></td>
                            </tr>
                            <tr>
                                <th>Ruolo:</th>
                                <td><?php echo $this->contact_roles[$contact['fab_contacts_role']]?></td>
                            </tr>
                            <tr>
                                <th>Email Principale:</th>
                                <td><?php echo $contact['contact_email']?></td>
                            </tr>
                            <tr>
                                <th>Tel Principale:</th>
                                <td><?php echo $contact['contact_phone']?></td>
                            </tr>		
                                <?php endforeach;
                            endif; ?>                  
                        </tbody>
                    </table> 
                </div>
            </div> 
        </div>

       <div id="detailTableRight">
            <table cellspacing="0" class="table">
                <caption><strong>Mappa</strong></caption>
                <tfoot>
                    <tr>
                        <td>
                            <a class="button" href="/admin/contatti/associa/id/<?php echo $this->data['contact_id']?>">Modifica</a>
                        </td>
                    </tr>
                </tfoot>
                <tbody>

                    <tr>
                        <?php if( $address !== NULL ) : ?>
                        <td id="map-container">
                            <div id="map-frame">
                                <!-- Mappa -->
                            </div>
                        </td>
                        <?php else: ?>
                        <td><i>Non ci sono abbastanza informazioni sull'indirizzo...</i></td>
                        <?php endif; ?>
                    </tr>

                </tbody>
            </table>
        </div> 
    </div>
<!--    Fine Dove?  -->
<br class="clear"/>
</div>
<script type="text/javascript">
    //<![CDATA[
    
    $("#map-frame").ready(function()
    {
	geocoder = new google.maps.Geocoder();
	/* Info Locale */
	var address	= "<?php echo $this->data['location']['location_name'] .','. $this->data['location']['location_street'] .','.$this->data['location']['location_street_number'] .','. $this->data['location']['location_city'] .' ('.$this->province[$this->data['location']['location_province_id']]['province_long_name'] .')' ?>";
	var title	= "<?php echo $this->data['location']['location_name']?>";

	var myOptions = {
	    zoom: 16,
	    mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	/* Istanzia la mappa */
	var map = new google.maps.Map(document.getElementById("map-frame"),myOptions);

	geocoder.geocode( { 'address': address}, function(results, status) {
	    if (status == google.maps.GeocoderStatus.OK) {
		map.setCenter(results[0].geometry.location);
		var marker = new google.maps.Marker({
		    map: map,
		    position: results[0].geometry.location,
		    animation: google.maps.Animation.DROP,
		    title: title
		});
	    } else {
		alert("Geocode fallito: " + status);
	    }
	});
    });

    //]]>
</script>